/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-09 15:24:06
 * @LastEditTime : 2023-08-27 13:30:13
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\LiveVideo.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, AnnexButton } from '../Common/options'

export const LiveVideo = ({ url, OptionsEvent, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '5e4e0d3d-b7d6-4dab-be35-2ed2b0a03bf8') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '直播名称' },
            {
                dataIndex: 'liveUrl',
                title: '直播地址',
                valueType: 'input',
                rules: true,
                ellipsis: true,
                width: 400,
            },
            { ...commonTableList.remark, title: '推流地址' },
            { ...commonTableList.isEnabled, rules: true },
            { ...commonTableList.sortId, rules: true },
            {
                dataIndex: 'coverAttachmentUuid',
                title: '直播封面',
                valueType: 'upload',
                valueFile: [1],
                fileUrl: 'coverUrl',
                hideInTable: true,
            },
            {
                dataIndex: 'coverUrl',
                title: '直播封面',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
                hideInTable: true,
                width: 400,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 320,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { coverUrl, liveUrl } = record
                    return [
                        Permission.findIndex(v => v.uuid === '5f83e814-9031-439e-90c9-7d56b943aad4') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        coverUrl && (
                            <AnnexButton OptionsEvent={OptionsEvent} key="see1" url={coverUrl} title="查看封面" />
                        ),
                        liveUrl && (
                            <AnnexButton OptionsEvent={OptionsEvent} key="see2" url={liveUrl} title="查看直播" />
                        ),
                        Permission.findIndex(v => v.uuid === 'e2da0dc8-c3ee-458c-a76d-4dcad15f59d7') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
